#ifndef MANAGERBERTHIER_H_
#define MANAGERBERTHIER_H_

#include <ext/hash_map>
#include <string>
#include <queue>
#include <list>
#include "URL.h"
#include "URLFileDealer.h"
#include "Dominio.h"
#include <ctime>

class URLComparison
{
public:
  bool operator() (const URL& lhs, const URL &rhs) const
  {
    return ( int( lhs.getDepth() ) > int( rhs.getDepth() ) );
  }
};

class ManagerBerthier {
private:
    ManagerBerthier();
    void refillQueue();
    std::string getRobots(std::string);
    
public:
    URL getNewURL();
    static ManagerBerthier &getInstance();
    void addURLs(std::list<URL>);
    virtual ~ManagerBerthier()
    {
        instanceFlag = false;
    }
    
    
private:
    static std::auto_ptr<ManagerBerthier> theManagerBerthier;
    const int timeBetweenVisits;
	std::priority_queue<URL, std::vector<URL>, URLComparison > urlQueue;
	__gnu_cxx::hash_map<unsigned int, Dominio *> domainHashMap;
};



#endif /*MANAGERBERTHIER_H_*/
